package org.csmzxy233401;
 class Animal2{
    public void speak(){
        System.out.println("动物发出叫声");
    }
}
class Cat extends Animal2{
    @Override
    public void speak(){
        System.out.println("小猫：喵喵……");
    }
}
class Dog extends Animal2{
    @Override
    public void speak(){
        System.out.println("小狗：汪汪……");
    }
    public void houseKeep(){
        System.out.println("狗狗会看家");
    }
}
public class example15 {
    public static void main(String[] args) {
        Animal2 animal = new Cat();
        if(animal instanceof Dog){
            Dog dog = (Dog) animal;
            dog.houseKeep();
        }else{
            System.out.println("对象类型向下转换不合法");
        }
    }
}